package com.chehongwei.aspect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MyAdvice
    implements Advice {

    @Override
    public Object invoke(
        Object target,
        Method method,
        Object[] args)
        throws InvocationTargetException, IllegalAccessException {

        long startTime = System.currentTimeMillis();
        Object ret = method.invoke(target, args);

        long endTime = System.currentTimeMillis();

        System.out.println("记录： "
            + target.getClass().getName()
            + "  "
            + method.getName()
            + "  耗时： "
            + (endTime - startTime)
            + "毫秒");

        return ret;
    }
}
